package com.fandou.airobot.database;

import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.Keep;
import androidx.room.Entity;
import androidx.room.PrimaryKey;

/**
 * @author Jm
 * @date 2020/7/9 15:14
 * @description 记录模式历史记录实体类
 */
@Keep
@Entity
public class Record implements Parcelable {

    @PrimaryKey(autoGenerate = true)
    public long id;

    /**
     * 1.点击开始记录时的时间戳，相当于记录时间
     * 2.也是拍照时保存图片到本地的文件名的前缀，用于标识是否为同一批次的图片
     */
    public long timestamp;

    /**
     * 合成视频的封面图片路径
     */
    public String coverPath;

    /**
     * 生成的视频路径
     */
    public String videoPath;

    /**
     * 预留字段
     * 标识当前视频是否已经发送
     */
    public boolean isSend;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    public String getCoverPath() {
        return coverPath;
    }

    public void setCoverPath(String coverPath) {
        this.coverPath = coverPath;
    }

    public String getVideoPath() {
        return videoPath;
    }

    public void setVideoPath(String videoPath) {
        this.videoPath = videoPath;
    }

    public boolean isSend() {
        return isSend;
    }

    public void setSend(boolean send) {
        isSend = send;
    }

    public Record(long timestamp, String coverPath, String videoPath) {
        this.timestamp = timestamp;
        this.coverPath = coverPath;
        this.videoPath = videoPath;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(this.id);
        dest.writeLong(this.timestamp);
        dest.writeString(this.coverPath);
        dest.writeString(this.videoPath);
        dest.writeByte(this.isSend ? (byte) 1 : (byte) 0);
    }

    protected Record(Parcel in) {
        this.id = in.readLong();
        this.timestamp = in.readLong();
        this.coverPath = in.readString();
        this.videoPath = in.readString();
        this.isSend = in.readByte() != 0;
    }

    public static final Creator<Record> CREATOR = new Creator<Record>() {
        @Override
        public Record createFromParcel(Parcel source) {
            return new Record(source);
        }

        @Override
        public Record[] newArray(int size) {
            return new Record[size];
        }
    };
}
